<?php

namespace app\admin\controller;

use think\Request;
use think\facade\View;
use app\common\model\SiteSetting;

class BaseController
{

    /**
     * 控制器中间件
     * @var array
     */
    protected $middleware = [
        'login', // 登录中间件
        'auth',  // 权限认证中间件
    ];

    /**
     * 分页当前页数
     * @var
     */
    public $page;

    /**
     * 分页每条查询条数
     * @var
     */
    public $limit;

    /**
     * 请求数据
     * @var
     */
    public $method;

    /**
     * 中间件获取的用户信息
     * @var
     */
    public $admin_info;

    /**
     * 获取当前控制器方法
     * @var
     */
    public $action;

    public function __construct(Request $request)
    {

        $this->admin_info = session('admin_info');
        $this->method  = $request->method();
        $this->page    = $request->param('page', 1);
        $this->limit   = $request->param('limit', 15);
        $this->action  = $request->url();

        //给模板传入当前控制器和方法名，用于跳转
        View::assign('action', $this->action);
        //网站配置
        $site_info = SiteSetting::getSite();
        View::assign('site_info', $site_info);
    }

}
